/* ********************发送注册AJAX**************** */

function registerOperation() {
    //1.获取参数
    var acc = $('#account').val();
    var pwd = $('#pwd').val();
    var repwd = $('#repwd').val();
    var niname = $('#niname').val();
    var sex = $("[name='sex']:checked").val();
    var edu = $('#edu').val();
    var pro = $('#pro').val();
    var tel = $('#tel').val();
    var email = $('#email').val();
    console.log(acc, pwd, repwd, niname, sex, edu, pro, tel, email);
    //2.判断密码
    if (pwd != repwd) {
        layer.confirm("2次密码输入的不一样，请重新输入", { btn: ['确定'] });
        return;
    }
    if (acc == "" || pwd == "" || repwd == "" || niname == "" || sex == "" || edu == "" ||
        pro == "" || tel == "" || email == "") {
        layer.confirm("输入框中不能有空，请重新输入", { btn: ['确定'] });
        return;
    }
    //3.发送AJAX
    $.ajax({
        url: "user/userRegister",
        type: "post",
        dataType: "JSON",
        data: {
            userName: acc,
            userNiname: niname,
            userPwd: repwd,
            userState: 1,
            userSex: sex,
            userEdu: edu,
            userPro: pro,
            userEmail: email,
            userTel: tel
        },
        success: function(data) {
            if (data.id == 0) {
                layer.confirm(data.message, { btn: ['确定'] });
            } else if (data.id == 1) {
                layer.confirm(data.message, {
                    btn: ['确定'] //按钮
                }, function() {
                    location.href = "page?p=" + data.location;
                });
            }
        }
    });


}
//注册按钮事件
$('#registerBtn').click(function() {
    registerOperation();
});